00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00033
00034 require_once (PATH_TO_ROOT . "messaging/classes/class.messaging_view.inc.php");
00035
00036 class MessagingIn extends MessagingView {
00037
00043 private $sortby;
00044
00050 private $order;
00051
00057 private $filter;
00058
00063 public function __construct($messaging) {
00064
00065 parent::__construct ( $messaging );
00066 }
00067
00072 protected function initView() {
00073
00074 if (isset ( $_GET ["sortby"] )) {
00075 switch ($_GET ["sortby"]) {
00076 case "von" :
00077 $this->sortby = "user.Nachname";
00078 break;
00079
00080 case "betreff" :
00081 $this->sortby = "messaging_inbox.subject";
00082 break;
00083
00084 case "datum" :
00085 $this->sortby = "messaging_inbox.date";
00086 break;
00087
00088 default :
00089 $this->sortby = "messaging_inbox.date";
00090 break;
00091 }
00092 } else {
00093 $this->sortby = "messaging_inbox.date";
00094 }
00095
00096
00097 if (isset ( $_GET ["order"] ) && $_GET ["order"] == "auf")
00098 $this->order = "ASC";
00099 else {
00100 $this->order = "DESC";
00101 }
00102
00103
00104 if(isset($_POST ["filterText"])) {
00105 $this->filter = Data::toMysql(Data::toHTML($_POST["filterText"]));
00106 }
00107 else {
00108 $this->filter = NULL;
00109 }
00110 return true;
00111 }
00112
00117 protected function checkActions() {
00118 if (isset ( $_GET ["action"] ) && $_GET ["action"] == "delete") {
00119 $this->messaging->deleteMessage ( $_GET ["messageID"], "inbox" );
00120 }
00121 if (isset ( $_POST ["deleteButton"] )) {
00122 $messages = array ();
00123 if (isset ( $_POST ["selectedMessages"] ))
00124 $messages = $_POST ["selectedMessages"];
00125 $count = count ( $messages );
00126 for($i = 0; $i < $count; $i ++) {
00127 $deleteReturn = $this->messaging->deleteMessage ( $messages [$i], "inbox" );
00128 if(!$deleteReturn) {
00129 Output::echoMessage ($this->translate->_("Fehler beim Loeschen der Nachricht!"), 0, true );
00130 break;
00131 }
00132 Output::echoMessage ($this->translate->_("Nachricht erfolgreich geloescht!"), 0, true );
00133 }
00134 } elseif (isset ( $_POST ["archiveButton"] )) {
00135 $messages = array ();
00136 if (isset ( $_POST ["selectedMessages"] ))
00137 $messages = $_POST ["selectedMessages"];
00138 $count = count ( $messages );
00139 for($i = 0; $i < $count; $i ++) {
00140 $this->messaging->archiveMessage ( $messages [$i], "inbox" );
00141 }
00142 } elseif (isset ( $_POST ["markAsReadButton"] )) {
00143 $messages = array ();
00144 if (isset ( $_POST ["selectedMessages"] ))
00145 $messages = $_POST ["selectedMessages"];
00146 $count = count ( $messages );
00147 for($i = 0; $i < $count; $i ++) {
00148 $this->messaging->markMessageAsRead ( $messages [$i] );
00149 }
00150 }
00151 return true;
00152 }
00153
00159 public function echoInbox() {
00160 if ($this->execution) {
00161 global $settings;
00162
00163 echo "<form id='messageAction' method='post' action='" . PATH_TO_ROOT . SCRIPT_NAME . "'>
00164 <table class='tableBorder' width='100%'>";
00165 Output::echoTableHead ($this->translate->_("Empfangene Nachrichten"), 4 );
00166
00167 echo "<tr><td colspan='4'>".($settings ["pm_days_to_delete_messages"] > 0 ? "<span class='text10'>".
00168 sprintf($this->translate->_("Hinweis: Nicht archivierte Nachrichten werden nach %1\$s Tagen geloescht."),$settings["pm_days_to_delete_messages"]).
00169 "</span>" : "");
00170
00171 echo "</td></tr>";
00172
00173
00174 if (isset($this->filter)) {
00175 $filterText = Data::toMysql ( Data::toHTML ($this->filter) );
00176 $sql = "SELECT user.Vorname, user.Nachname, user.gender, messaging_inbox.*, messaging_inbox.date
00177 FROM user RIGHT JOIN messaging_inbox
00178 ON user.ID = messaging_inbox.authorID
00179 WHERE messaging_inbox.userID =" . $this->messaging->getUserID () . " AND messaging_inbox.subject LIKE '%" . $filterText . "%' ORDER BY " . $this->sortby . " " . $this->order;
00180 }
00181 else {
00182 $sql = "SELECT user.Vorname, user.Nachname, user.gender, messaging_inbox.*, messaging_inbox.date
00183 FROM user RIGHT JOIN messaging_inbox
00184 ON user.ID = messaging_inbox.authorID
00185 WHERE messaging_inbox.userID =" . $this->messaging->getUserID () . " ORDER BY " . $this->sortby . " " . $this->order;
00186 }
00187
00188 $messages = $this->db->get_results ( $sql );
00189
00190
00191 if ($this->db->num_rows > 0) {
00192
00193
00194 if (isset ( $this->filter ) && $this->filter != "")
00195 {
00196 Output::echoMessage ($this->translate->_("Filter").": " . $this->filter, 4 );
00197
00198 echo "<tr>
00199 <td class='tableCellHead'>".$this->translate->_("Absender")."</td>
00200 <td class='tableCellHead'>".$this->translate->_("Betreff")."</td>
00201 <td class='tableCellHead'>".$this->translate->_("Datum")."</td>
00202 <td class='tableCellHead'><a href='" . PATH_TO_ROOT . "pdf/build.php?type=pdf&target=pn&id=recv'>" . Output::getIcon ( "icon_pdf", $this->translate->_("Alle empfangenen Nachrichten als PDF exportieren")) . "</a>
00203 </td>
00204 </tr>";
00205 } else {
00206 echo "<tr>
00207 <td class='tableCellHead'><a href='" . PATH_TO_ROOT . SCRIPT_NAME . "?sortby=von&order=" . $this->messaging->getOrderByLink ( "von" ) . "'>".$this->translate->_("Absender")."</a></td>
00208 <td class='tableCellHead'><a href='" . PATH_TO_ROOT . SCRIPT_NAME . "?sortby=betreff&order=" . $this->messaging->getOrderByLink ( "betreff" ) . "'>".$this->translate->_("Betreff")."</a></td>
00209 <td class='tableCellHead'><a href='" . PATH_TO_ROOT . SCRIPT_NAME . "?sortby=datum&order=" . $this->messaging->getOrderByLink ( "datum" ) . "'>".$this->translate->_("Datum")."</a></td>
00210 <td class='tableCellHead'><a href='" . PATH_TO_ROOT . "pdf/build.php?type=pdf&target=pn&id=recv'>" . Output::getIcon ( "icon_pdf", $this->translate->_("Alle empfangenen Nachrichten als PDF exportieren")) . "</a>
00211 </td>
00212 </tr>";
00213 }
00214
00215 $darkCell = true;
00216
00217
00218 foreach ( $messages as $message ) {
00219 if ($message->isRead == 0) {
00220 echo "<tr style='font-weight:bold;' valign='top'>";
00221 $image = Output::getIcon ( "icon_mail", $this->translate->_("Nachricht ungelesen"));
00222 } else {
00223 echo "<tr valign='top'>";
00224 $image = "";
00225 }
00226
00227 if ($message->isArchived == 1)
00228 $image = Output::getIcon ( "icon_emailarchiv", $this->translate->_("Nachricht im Archiv") );
00229
00230
00231 $date = new Zend_Date($message->date, Zend_Date::TIMESTAMP);
00232 $date = $date->get(Zend_Date::DATE_SHORT)." - ".$date->get(Zend_Date::TIME_SHORT);
00233
00234 $message->date = $date;
00235 $darkCell == true ? $class = "tableCellDark" : $class = "tableCell";
00236 $userLink = "<a href='" . PATH_TO_ROOT . "user/homepage.php?user=" . $message->authorID . "'>" . Data::toHTML ( "$message->Vorname $message->Nachname", false ) . "</a>";
00237
00238 $role = RoleArtefacts::getRoleForItem ( PM, ( int ) $message->ID );
00239 if ($role) {
00240 $userLink .= " (" . $role->getPropertiesLink ( $role->getName ( $message->gender ), $this->translate->_("Rollen-Eigenschaften anzeigen"), true ) . ")";
00241 }
00242
00243
00244 echo "<td class='" . $class . "'>$userLink</td>
00245 <td class='" . $class . "'><a href='" . PATH_TO_ROOT . "messaging/" . PATH_TO_MESSAGE_DETAIL . "?type=inbox&messageID=" . $message->ID . "'>" . $image . $message->subject . "</a></td>
00246 <td class='" . $class . "'>" . $message->date . "</td>
00247 <td class='" . $class . "' align='center'><p class='pForm'><input type='checkbox' name='selectedMessages[]' value='" . $message->ID . "' ";
00248 if (isset ( $_POST ["markAll"] ))
00249 echo "checked='checked' ";
00250 echo "/></p></td></tr>";
00251 $darkCell == true ? $darkCell = false : $darkCell = true;
00252 }
00253 $filterzeile = "<p class='pForm'>".$this->translate->_("Betreffzeile filtern nach").": <input type='text' name='filterText' value='" . $this->filter . "'/> <input type='submit' name='filterButton' value='".$this->translate->_("Filter anwenden")."'/></p> ";
00254
00255 Output::echoDialogBottom ( array ("okButton" => "", "resetButton" => "", "cancelButton" => "" ), 4, true, $filterzeile);
00256
00257
00258 $bottomButtons = "</p> <p class='pForm'><input type='submit' name='markAsReadButton' value='".$this->translate->_("Als gelesen markieren")."'/>
00259 </p> <p class='pForm'><input type='submit' name='deleteButton' value='".$this->translate->_("Loeschen")."'/></p>
00260 <p class='pForm'><input type='submit' name='archiveButton' value='".$this->translate->_("Archivieren")."'/></p> ";
00261
00262 if (isset ( $_POST ["markAll"] )) {
00263 $bottomButtons = "<p class='pForm'><input type='submit' name='markNone' value='".$this->translate->_("Nichts markieren")."'/>".$bottomButtons;
00264 Output::echoDialogBottom ( array ("okButton" => "", "cancelButton" => "" ), 4, true, $bottomButtons);
00265 } else {
00266 $bottomButtons = "<p class='pForm'><input type='submit' name='markAll' value='".$this->translate->_("Alles markieren")."'/>".$bottomButtons;
00267 Output::echoDialogBottom ( array ("okButton" => "", "cancelButton" => "" ), 4, true, $bottomButtons);
00268 }
00269 }
00270
00271
00272 else if (($this->db->num_rows == 0) and (isset ( $this->filter )) and ($this->filter != ""))
00273 {
00274
00275 Output::errorMessage ($this->translate->_("Filter").": " . $this->filter, 4 );
00276 echo "<tr><td>".$this->translate->_("Keine Nachrichten die dem Filter entsprechen")."</td></tr>";
00277
00278
00279 Output::echoDialogBottom ( array ("okButton" => "", "resetButton" => "", "cancelButton" => "" ), 4, true, $filterzeile);
00280 }
00281 else {
00282 echo "<tr><td>".$this->translate->_("Keine neuen Nachrichten").".</td></tr>";
00283 }
00284
00285 echo "</table></form>";
00286 }
00287 }
00288 }
00289 ?>